package com.twu.biblioteca;

import java.io.*;

public class Console {
    private BufferedReader reader;
    private BufferedWriter writer;

    Console(){
        reader = new BufferedReader(new InputStreamReader(System.in));
        writer = new BufferedWriter(new OutputStreamWriter(System.out));

    }


    public int readInteger() throws Exception {
        String input = null;
        int result = 0;

        try {
            input = reader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try{
            result = Integer.parseInt(input);
        }
        catch(Exception e){
            throw e;
        }
        return result;
    }

    public String readString(){
        String input = null;
        try {
            input = reader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return input;
    }


    public void write(String output){
        try {
            writer.write(output);
            writer.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public String readString(String msg) {
        write(msg);
        return readString();
    }
}
